#include <algorithm>
#include <cstdio>
#include <set>

const int N = 100005;
int n, num;
std::set<int> set;

struct Node {
  int x, y;
  bool typ;
  inline bool operator<(const Node &rhs) const { return x < rhs.x; }
} eve[N << 1];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("guide.in", "r", stdin);
  freopen("guide.out", "w", stdout);
#endif
#endif

  scanf("%d", &num);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &eve[i].x, &eve[i].y);
    eve[i].typ = false;
  }
  n <<= 1;
  for (int i = (n >> 1) + 1; i <= n; ++i) {
    scanf("%d%d", &eve[i].x, &eve[i].y);
    eve[i].typ = true;
  }
  int ans = 0;
  std::sort(eve + 1, eve + n + 1);
  std::set<int>::iterator iter;
  for (int i = 1; i <= n; ++i) {
    if (eve[i].typ) {
      if ((iter = set.upper_bound(eve[i].y)) == set.begin()) {
        ++ans;
      } else {
        set.erase(--iter);
      }
    } else {
      set.insert(eve[i].y);
    }
  }
  printf("%d", (n >> 1) - ans);
  return 0;
}